import { Directive } from 'vue'

export const redText: Directive = {
  beforeMount(el: HTMLElement, binding) {
    const text = el.innerText
    text.replace(`/${binding.value}/g`, `<span style="color:red">${binding.value}</span>`)
    el.innerHTML = text
  },
  unmounted(el: HTMLElement) {
   
  }
}

// 使用方式: <div v-red-text='1'> 123456789098765432</div>